home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CTFASMTT.ZIP / LESSON6.DOC < prev    next >
Text File  |  1994-10-29  |  2KB  |  88 lines

  1. LESSON6 - MEMORY MOVING
  2.  
  3. lets say I want to move from one memory point to another lets say
  4. for now the text screen, (seg is 0b800h and it's size is 4000 bytes)
  5.  
  6. so we have to use some very special command :
  7.  
  8. MOVSB       - Moves string byte, moves one byte from DS:SI to ES:DI and if
  9.               the CF is 0 (CLD is the command thats set is to 0) then
  10.               both si and di are incremented, if CF is 1 then (STD)
  11.               si and di are decremented.
  12. MOVSW       - Moves string word, moves one word (2 bytes) from DS:SI to ES:DI
  13.               the method of incrementing is the same like movsb just it does
  14.               it by 2 and by 1 byte.
  15. REP command - Repeats a certain command lets say "rep movsw" it will preform
  16.               movsw in a loop and which cx defines how much, if cx is 10 then
  17.               the movsw will be done 10 times.
  18.  
  19. now after we know those command lets implement them !!!!!!!!!!!!!!!!!
  20.  
  21. sseg segment
  22.   db 10 dup (?)
  23. ends
  24.  
  25. cseg segment
  26. assume cs:cseg,ss:sseg,ds:cseg,es:nothing
  27.  
  28. buf   db 4000 dup (?)
  29.  
  30. start :
  31.  
  32. push ds        ; we must save it
  33.  
  34. mov ax,seg buf ; we cannot type into segment registers directly
  35. mov ds,ax      ; it goes into simple register and then to the segment
  36. mov si,offset buf
  37.  
  38. mov ax,0b800h  ; adress of screen
  39. mov es,ax
  40. mov di,0
  41.  
  42. mov cx,2000    ; to speed up use movsw (4000 bytes/2)
  43. rep movsw
  44.  
  45. pop ds
  46.  
  47. mov ax,4c00h
  48. int 21h
  49. ends
  50. end start
  51. end
  52.  
  53. and thats is, but what I will do if I want lets say clear the memory
  54. with out using buffer or clearing the buffer it self ????
  55.  
  56. STOSB - Store string byte, stores al in ES:DI if the CF is 0 then
  57.         di is incremented, if CF is 1 then di is decremented.
  58. STOSW - Store string word, stores ax in ES:DI if the CF is 0 then
  59.         di is incremented, (by 2) if CF is 1 then di is decremented (by 2).
  60.                                                                ^
  61. now the procedure is almost the same as the moving of a buffer │
  62.  
  63. sseg segment
  64.   db 10 dup (?)
  65. ends
  66.  
  67. cseg segment
  68. assume cs:cseg,ss:sseg,ds:cseg,es:nothing
  69.  
  70. start :
  71.  
  72. push ds        ; we must save it
  73.  
  74. mov ax,0b800h  ; adress of screen
  75. mov es,ax
  76. mov di,0
  77.  
  78. mov cx,2000    ; to speed up use movsw (4000 bytes/2)
  79. mov ax,0       ; we want to clear it
  80. rep stosw      ; stores ax 2000 times in ES:DI (screen)
  81.  
  82. pop ds
  83.  
  84. mov ax,4c00h
  85. int 21h
  86. ends
  87. end start
  88. end